package com.example.kindergarten.exceptionHandler

/**
 * @description: 自定义异常类
 * @author: DT
 * @date: 2021/4/19 21:44
 * @version: v1.0
 */
class BizException : RuntimeException {
    /**
     * 错误码
     */
    var errorCode: String? = null

    /**
     * 错误信息
     */
    var errorMsg: String? = null

    constructor() : super() {}
    constructor(errorInfoInterface: BaseErrorInfoInterface) : super(errorInfoInterface.resultCode) {
        errorCode = errorInfoInterface.resultCode
        errorMsg = errorInfoInterface.resultMsg
    }

    constructor(errorInfoInterface: BaseErrorInfoInterface, cause: Throwable?) : super(
        errorInfoInterface.resultCode,
        cause
    ) {
        errorCode = errorInfoInterface.resultCode
        errorMsg = errorInfoInterface.resultMsg
    }

    constructor(errorCode:Int,errorMsg: String?) : super(errorMsg) {
        this.errorMsg = errorMsg
        this.errorCode = errorCode.toString()
    }

    constructor(errorCode: String?, errorMsg: String?) : super(errorCode) {
        this.errorCode = errorCode
        this.errorMsg = errorMsg
    }

    constructor(errorCode: String?, errorMsg: String?, cause: Throwable?) : super(errorCode, cause) {
        this.errorCode = errorCode
        this.errorMsg = errorMsg
    }

    override fun fillInStackTrace(): Throwable {
        return this
    }

    companion object {
        private const val serialVersionUID = 1L
    }
}
